package com.qf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.entity.TlBed;
import com.qf.entity.TlCity;
import com.qf.entity.TlHotel;
import com.qf.mapper.AdminBedMapper;
import com.qf.mapper.HotelMapper;
import com.qf.service.AdminBedService;
import com.qf.service.HotelService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminBedServiceImpl extends ServiceImpl<AdminBedMapper, TlBed> implements AdminBedService {
    @Autowired
    HotelMapper hotelMapper;
    @Override
    public ResultMsg findBed(Integer page,Integer limit) {
        Page<TlBed> bedPage = new Page<>(page, limit);
        Page<TlBed> page1 = super.page(bedPage);

        List<TlBed> records = page1.getRecords();
        for (TlBed record : records) {
            Integer hotelId = record.getHotelId();
            TlHotel tlHotel = hotelMapper.selectById(hotelId);
            record.setHotelName(tlHotel.getHotelName());
        }

        return ResultMsg.SUCCESS(page1);
    }

}
